package com.glorysoft.wangnianxinpda.adapter;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.glorysoft.wangnianxinpda.R;
import com.glorysoft.wangnianxinpda.adapter.viewholder.DataBindingBaseViewHolder;
import com.glorysoft.wangnianxinpda.databinding.AdapterBatchBinding;

import java.util.List;

/**
 * FileName: BatchAdapter
 * Author: XJH
 * Date: 2021/12/21 15:35
 * Description:
 * History:
 */
public class BatchAdapter extends BaseQuickAdapter<String, DataBindingBaseViewHolder> {
    public BatchAdapter(@Nullable List<String> data) {
        super(R.layout.adapter_batch,data);
    }

    @Override
    protected void convert(DataBindingBaseViewHolder helper, String item) {
        AdapterBatchBinding mBinding = (AdapterBatchBinding) helper.getDataBinding();
        helper.setText(R.id.tvPosition,String.valueOf(helper.getAdapterPosition() + 1));
        mBinding.setItem(item);
        mBinding.btnDelete.setOnClickListener(view -> {
            getData().remove(item);
            notifyDataSetChanged();
        });
        mBinding.executePendingBindings();

    }
}
